# -*- coding: utf-8 -*-
import time

from PyQt4 import QtGui

#Importa classes necessarias.
from ui.uiMain import UiMain
from db.dataBase import DataBase
from actions.actionsUiMain import ActionsUiMain
from gpib.prologixGpibEthernet import GPIB
from images import images_rc


class RunnerAppMain(QtGui.QMainWindow):

    def __init__(self, parent = None):
        """
            Constructor.
        """
        QtGui.QWidget.__init__(self, parent)
        self.setupUi()



    def setupUi(self):
        """
            Metodo que instancia as classes utilizadas.
        """
        self.uiMain = UiMain()
        self.uiMain.setupUi(self)
        self.db = DataBase()
        self.gpib = GPIB(self)
        self.actionsUiMain = ActionsUiMain(self.uiMain, self.db, self.gpib)



    def run(self):
        """
            Metodo que executa a aplicacao.
        """
        pic = QtGui.QPixmap(':/vna-icon/splash.jpg')
        splash = QtGui.QSplashScreen(pic)
        splash.show()
        splash.showMessage('Iniciando programa ...')
        time.sleep(2)
        splash.finish(self)
        self.show()



if __name__ == "__main__":
    import sys
    appMain = QtGui.QApplication(sys.argv)
    appMain.processEvents()
    runner = RunnerAppMain()
    appMain.processEvents()
    appMain.setWindowIcon(QtGui.QIcon(":/vna-icon/tsm.jpg"))
    runner.run()
    appMain.exec_()
